package com.yy.micro.magic.data.service.rule.impl;

import com.yy.micro.magic.data.domain.MagicRuleVo;
import com.yy.micro.magic.data.entity.MagicRuleEntity;
import com.yy.micro.magic.data.repository.MagicRuleRepository;
import com.yy.micro.magic.data.service.rule.MagicRuleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class MagicRuleServiceImpl implements MagicRuleService {
    @Autowired
    private MagicRuleRepository repository;
    @Override
    public MagicRuleVo save(MagicRuleVo node) {
        MagicRuleEntity rule= repository.save(node.to());
        return MagicRuleVo.create().from(rule);
    }

    @Override
    public MagicRuleVo load(long nodeId) {
        MagicRuleEntity rule= repository.findById(nodeId).get();
        return MagicRuleVo.create().from(rule);
    }
}
